<?php

namespace app\common\model;

use think\Model;

/**
 * em_order_balance_log
 * @property integer $id (主键)
 */
class OrderBalanceLog extends Model
{
    /**
     * The connection name for the model.
     *
     * @var string|null
     */
    protected $connection = 'mysql';
    
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'em_order_balance_log';
    
    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $pk = 'id';
    
    const DESCARR = ['错误费用BUG', '杂费', '垫付运费', '客户现付', '客户到付', '平台费用', '归还垫付运费'];
    
    protected $feeType = [''];
    
    /**
     * @param int $type 1.公司余额记录 2.平台余额记录 3.客户余额记录 4.司机余额记录
     * @param $changeType
     * @param int $companyId
     * @param float $change
     * @return OrderBalanceLog|Model|void
     */
    public static function set(int $type = 0, $changeType = 0, int $deptId = 0, float $change = 0.00)
    {
        // 1.公司余额记录 2.平台余额记录 3.客户余额记录 4.司机余额记录
        return self::create([
            'type' => $type,
            'change' => $change,
            'change_type' => $changeType,
            'dept_id' => $deptId,
            'description' => self::DESCARR[$changeType],
            'create_time' => date('Y-m-d H:i:s')
        ]);
    }
    
}
